#!/usr/bin/python
# -*- coding: utf-8 -*-
# @version        : 1.0
# @Create Time    : 2025/3/25 11:11
# @File           : vendor
# @IDE            : PyCharm
# @desc           : 描述


import json
from fastapi import Depends
from core.dependencies import Paging, QueryParams


class TaskWorkTeamParams(QueryParams):
    """
    列表分页
    """

    def __init__(
            self,
            params: Paging = Depends(),
            ticket_id: str = None,
            name: str = None,
            work_no: str = None,
            send_message: bool = None,
            task: str = None
    ):
        super().__init__(params)
        self.ticket_id = ticket_id
        self.name = name
        self.work_no = work_no
        self.send_message = send_message
        self.task = None
        if task:
            self.task = {}
            task = json.loads(task)
            for key, value in task.items():
                if key in ["start", "end", "plan_start", "plan_end"]:
                    self.task[key] = ('between', value.split(","))
                elif key in ["team_leader", "ao_id", "ao_name", "plan_user"]:
                    self.task[key] = ("like", value)
                elif "," in value:
                    self.task[key] = ('in', [i.strip() for i in value.split(",")])
                else:
                    self.task[key] = value
